<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Http\Controllers\Backend\Dances;

/**
 * Description of CourseBookingController  预约列表
 *
 * @author Admin
 */

use Illuminate\Http\Request;
use App\Http\Models\Student\CourseBookingService;

class CourseBookingController
{

    private $courseBookingService;
    private $request;

    public function __construct(CourseBookingService $courseBookingService, Request $request)
    {
        $this->courseBookingService = $courseBookingService;
        $this->request = $request;
    }

    public function index()
    {
        $courseBookingDatas = $this->courseBookingService->index($this->request);
        return view("backend.courseBooking.index", [
            'courseBookingDatas' => $courseBookingDatas,
            'request'            => $this->request
        ]);
    }

    public function show($id)
    {
        $courseBookingData = $this->courseBookingService->show($id);
        return view('backend.courseBooking.show', [
            'courseBookingData' => $courseBookingData,
        ]);
    }

    public function edit($id)
    {
        $dancesList = $this->courseBookingService->getDances();
        $courseBookingData = $this->courseBookingService->show($id);
        return view('backend.courseBooking.update', [
            'courseBookingData' => $courseBookingData,
            'dancesList'        => $dancesList
        ]);
    }

    public function update(StudentFrom $rotaionFrom, $id)
    {
        $this->courseBookingService->updateSave($rotaionFrom, $id);
        return redirect('admin/courseBooking');
    }

    public function destroy($id)
    {
        return $this->courseBookingService->remove($id);
    }

}
